﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.ComponentModel;

namespace TimeReporter_II
{
    public class ProjectList : INotifyPropertyChanged, IProjectList
    {
        private string _pathToFiles;
        private ObservableCollection<ProjectObject> _collection;

        private static ProjectList instance = new ProjectList();

        public event PropertyChangedEventHandler PropertyChanged;
        
        private void NotifyPropertyChanged(string info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }
        
        private ProjectList() : base()
        {
            _collection = new ObservableCollection<ProjectObject>();
        }

        public static ProjectList getInstance()
        {
            return instance;
        }

        public string PathToFiles
        {
            get { return _pathToFiles; }
            set {
                if (value != null && value != _pathToFiles)
                {
                    _pathToFiles = value;
                    NotifyPropertyChanged("PathToFiles");
                }
            }
        }

        public void AddProject(ProjectObject po)
        {
            this._collection.Add(po);
        }

        public ObservableCollection<ProjectObject> getList()
        {
            return _collection;
        }
    }
}
